# 全部商品
product_list = [
    ("iphone", 5000),
    ("Macbook", 12000),
    ("AppleWatch", 3000),
    ("airpods", 1000),
    ("ipad", 4000)
]

# 已购买商品
shopping_product = []


# 展示所有商品列表
def show():
    i = 1
    for p in product_list:
        print("{}.{} {}".format(i, p[0], p[1]))
        i += 1


show()
salary = int(input("请输入每月工资:"))
while True:
    shopping_num = int(input("是否购买商品 如果购买请输入商品序号，不购买按-1退出"))
    if shopping_num == -1:
        print("下面是购买的商品")
        for p in shopping_product:
            print(p[0])
        print("余额{}".format(salary))
        break
    else:
        product = product_list[shopping_num - 1]
        if product[1] <= salary:
            shopping_product.append(product)
            salary -= product[1]
            print("您购买的商品为{},余额{},交易成功".format(product[0], salary))
        else:
            print("余额不足!")